<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head th:replace="admin/_fragments::head(~{::title})">
		<meta charset="utf-8">
		<!-- 设置移动端更好的适配以及预览 -->
		<meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title>博客发布</title>
		<!-- 引入semantic-ui的css和js -->
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
		<link rel="stylesheet" href="../../static/css/me.css"/>
		<!--引入md编辑器的css样式-->
		<link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css">
	</head>
	<body>
		<!-- 导航栏部分 -->
		<nav th:replace="admin/_fragments::menu(1)" class="ui inverted attached segment m-padded-tb-mini m-shadow-small"><!-- inverted是反转的意思，默认效果是圆角的，我们可以使用attached是去除圆角 -->
			<div class="ui container">
				<div class="ui inverted secondary stackable menu">
					<h2 class="ui blue header item">Blog管理后台</h2>
					<a href="#" class="item menu-item m-mobile-hide"><i class="home icon"></i>博客</a>
					<a href="#" class="item menu-item m-mobile-hide"><i class="idea icon"></i>分类</a>
					<a href="#" class="item menu-item m-mobile-hide"><i class="tags icon"></i>标签</a>
					<div class="right menu-item m-mobile-hide menu">
						<div class="ui dropdown item">
							<div class="text">
								<img class="ui avatar image" src="../../static/images/huazai.png"  alt="图片加载失败"/>
								龙哥
							</div>
							<i class="dropdown icon"></i>
							<div class="menu">
								<a href="#" class="item">注销</a>
							</div>
						</div>
					</div>

				</div>
			</div>
			<!--绑定css样式:手机端显示，电脑端隐藏
				绑定js：当点击的时候，上面的菜单栏显示和隐藏进行切换。
			-->
			<a href="#" class="ui menu toggle black icon button m-top-right m-mobile-show">
				<i class="sidebar icon"></i>
			</a>
		</nav>
		<div class="ui container">
			<div class="ui right attached pointing menu">
				<a href="#" th:href="@{/admin/blogs}" class="item">列表</a>
				<a href="#" th:href="@{/admin/blogs/input}" class="active item">发布</a>
			</div>
		</div>



		<!-- 存放主体内容 -->
		<div class="m-padded-tb-big m-container-small">
			<div class="ui container">
				<form id="blog-form" action="#" th:object="${blog}" th:action="@{/admin/blogs}" method="post" class="ui form">
					<input type="hidden" name="published">
					<!--如果是修改主键就是非空的-->
					<input type="hidden" name="id" th:value="*{id}">
					<div class="required field">
						<div class="ui left labeled input">
							<div class="ui selection blue compact basic dropdown label">
								<input type="hidden" value="原创" name="flag" th:value="*{flag}">
								<i class="dropdown icon"></i>
								<div class="default text">原创</div>
								<div class="menu">
									<div class="item" data-value="原创">原创</div>
									<div class="item" data-value="转载">转载</div>
									<div class="item" data-value="翻译">翻译</div>
								</div>
							</div>
							<input type="text" name="title" placeholder="标题" th:value="*{title}">
						</div>
					</div>
					<div class="required field attached">
						<!--设定优先级：z-index: 1 !important;解决全屏的问题-->
						<div id="md-content" style="z-index: 1 !important;">
							<textarea placeholder="博客内容" name="content" style="display: none" th:text="*{content}">
								[TOC]
								#### Disabled options
								-TeX(Based on KaTeX);
								-Emoji;
								-Task lists;
								-HTML tags decode;
								-Flowchart and Sequence Diagram;
							</textarea>
						</div>
					</div>
					<div class="required field attached">
						<!--设定优先级：z-index: 1 !important;解决全屏的问题-->
						<div id="md-description" style="z-index: 1 !important;">
							<textarea placeholder="博客描述信息......." name="description" th:text="*{description}">
								博客信息描述
							</textarea>
						</div>
					</div>

					<div class="two fields">
						<div class="required field">
							<div class="ui left fluid labeled action input">
								<label class="ui compact blue basic label">分类</label>
								<div class="ui fluid selection dropdown">
									<input type="hidden" name="type.id" th:value="*{type}!=null?*{type.id}:''">
									<i class="dropdown icon"></i>
									<div class="default text">分类</div>
									<div class="menu">
										<div th:each="type:${types}" th:data-value="${type.id}" th:text="${type.name}" class="item" data-value="1">错误日志</div>
									</div>
								</div>
							</div>
						</div>
						<div class="field">
							<div class="ui left labeled action input">
								<label class="ui compact blue basic label">标签</label>
								<div class="ui tag multiple search fluid selection dropdown">
									<input type="hidden" name="tagIds" th:value="*{tagIds}">
									<i class="dropdown icon"></i>
									<div class="default text">标签</div>
									<div class="menu">
										<div th:each="tag:${tags}" th:data-value="${tag.id}" th:text="${tag.name}" class="item" data-value="1">标签</div>
									</div>
								</div>
							</div>
						</div>
					</div>

					<div class="required field">
						<div class="ui left labeled input">
							<label class="ui blue basic label">首图</label>
							<input type="text" name="firstPicture" placeholder="首图引用地址" th:value="*{firstPicture}">
						</div>
					</div>

					<div class="inline fields">
						<div class="field">
							<div class="ui checkbox">
								<input type="checkbox" id="recommend" name="recommend" checked class="hidden" th:checked="*{recommend}">
								<label for="recommend">推荐</label>
							</div>
						</div>
						<div class="field">
							<div class="ui checkbox">
								<input type="checkbox" id="shareStatement" name="shareStatement" class="hidden" th:checked="*{shareStatement}">
								<label for="shareStatement">转载声明</label>
							</div>
						</div>
						<div class="field">
							<div class="ui checkbox">
								<input type="checkbox" id="appreciation" name="appreciation" class="hidden" th:checked="*{appreciation}">
								<label for="appreciation">赞赏</label>
							</div>
						</div>
						<div class="field">
							<div class="ui checkbox">
								<input type="checkbox" id="commentabled" name="commentabled" class="hidden" th:checked="*{commentabled}">
								<label for="commentabled">留言</label>
							</div>
						</div>
					</div>
					<div class="ui error message"></div>
					<div class="ui right aligned container">
						<button type="button" class="ui mini red button" onclick="window.history.go(-1)">返回</button>
						<button type="button" id="save-btn" class="ui mini secondary button">保存</button>
						<button type="button" id="published-btn" class="ui mini green button">发布</button>
					</div>
				</form>

			</div>
		</div>


		<!-- 存放底部footer -->
		<!-- vertical:垂直的，默认情况下segment是圆角，-->
		<footer th:replace="admin/_fragments::footer" class="ui inverted vertical segment m-padded-tb-big">
			<!--设置一个居中的容器-->
			<div class="ui center aligned container">
				<!--grid:垂直划分，默认是16份；
					inverted divided：采用分割线  -->
				<div class="ui inverted stackable divided grid">
					<!--存放左边的二维码-->
					<diV class="three wide column">
						<div class="ui inverted link list">
							<div class="item">
								<!--rounded：设置图片为圆角-->
								<img src="../../static/images/wechat.jpg" class="ui rounded image" alt="图片加载失败" style="width: 100px;height: 100px;"/>
							</div>
						</div>
					</diV>
					<!--存放最新博客的信息-->
					<diV class="three wide column">
						<h4 class="ui inverted header  m-text-spaced m-opacity-mini">最新博客</h4>
						<div class="ui inverted link list">
							<a href="#" class="item">用户故事</a>
							<a href="#" class="item">早期的鸟儿有虫吃</a>
							<a href="#" class="item">早期的虫儿被鸟吃</a>
						</div>
					</diV>
					<!--存放联系我的相关信息-->
					<diV class="three wide column">
						<h4 class="ui inverted header m-text-spaced m-opacity-mini">联系我</h4>
						<div class="ui inverted link list">
							<a href="#" class="item">Email：p15194420545@163.com</a>
							<a href="#" class="item">QQ：1753853993</a>
						</div>
					</diV>
					<!--右侧的论坛介绍-->
					<diV class="seven wide column">
						<h4 class="ui inverted header m-text-spaced m-opacity-mini">论坛show</h4>
						<p class=" m-opacity-mini">这是我的个人博客，会分享一些关于编程，写作，思考相关的内容，希望可以给来到这里的人有所帮助...</p>
					</diV>
				</div>
				<!---->
				<div class="ui inverted section divider"></div>
				<p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright © 2016 - 2017 Lirenmi Designed by Lirenmi</p>
			</div>
			
		</footer>

		
		<!-- js文件依赖jquery，因此我们需要引入jquery -->
		<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
		<script src="../../static/lib/editormd/editormd.min.js" th:src="@{/lib/editormd/editormd.min.js}"></script>
		<script type="text/javascript">
			var contentEditor;
			$(function (){
				contentEditor=editormd("md-content",{
					width:"100%",
					height:640,
					syncScrolling: "single",
					path:"/lib/editormd/lib/"
				})
			});

			$('.menu.toggle').click(function (){
				$('.menu-item').toggleClass('m-mobile-hide');
			});
			$('.ui.dropdown').dropdown({
				on:'hover'
			});
			$('.ui.form').form({
				fields:{
					title:{
						identifier:'title',
						rules:[{
							type:'empty',
							prompt:'标题：请输入博客标题'
						}]
					},
					content:{
						identifier:'content',
						rules:[{
							type:'empty',
							prompt:'标题：请输入博客正文内容'
						}]
					},
					typeId:{
						identifier:'typeId',
						rules:[{
							type:'empty',
							prompt:'标题：请输入博客分类'
						}]
					},
					firstPicture:{
						identifier:'firstPicture',
						rules:[{
							type:'empty',
							prompt:'标题：请输入博客首图'
						}]
					},
					description:{
						identifier:'description',
						rules:[{
							type:'empty',
							prompt:'标题：请输入博客描述信息'
						}]
					},
				}
			});
			$("#save-btn").click(function () {
				$("[name='published']").val(false);
				$("#blog-form").submit();
			})
			$("#published-btn").click(function () {
				$("[name='published']").val(true);
				$("#blog-form").submit();
			})
			$('.ui.tag.dropdown').dropdown({
				allowAdditions:true
			});
		</script>
	</body>
</html>
